﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace NuaTarDoneng.Tail
{
    public static class Logs
    {
        public static void Log(HttpContext cts, string a)
        {
            string date = DateTime.Now.ToString("yyyy/MM/dd/ HH:mm:ss");
            string ip = cts.Request.UserHostAddress;
            StreamWriter sw = new StreamWriter(cts.Server.MapPath("/Tail/Log.txt"), true, System.Text.Encoding.UTF8);
            sw.WriteLine(date + "\t" + a+"\t"+ip);
            sw.Flush();
            sw.Close();
        }
        public static void Cleans(HttpContext cts)
        {
            File.Delete(cts.Server.MapPath("/Tail/innerLog.txt"));
            File.Delete(cts.Server.MapPath("/Tail/Log.txt"));
        }
        public static void InnerLog(string path, string a)
        {
            string date = DateTime.Now.ToString("yyyy/MM/dd/ HH:mm:ss");
            StreamWriter sw = new StreamWriter(path+"Tail/innerLog.txt", true, System.Text.Encoding.UTF8);
            sw.WriteLine(date + "\t" + a);
            sw.Flush();
            sw.Close();
        }
    }
}